﻿using System;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

[RequireComponent(typeof(Toggle))]
public class SetToggleOnOnSelected : MonoBehaviour
{
    private GameObject go;
    private Toggle toggle;

    private void Awake()
    {
        this.go = base.gameObject;
        this.toggle = base.GetComponent<Toggle>();
    }

    private void Update()
    {
        if (EventSystem.current.currentSelectedGameObject == this.go)
        {
            this.toggle.isOn = true;
        }
    }
}

